home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3990 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.delphi.com!usenet
  2. From: Derek Harmon <stonelight@delphi.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What's wrong here?
  5. Date: Thu, 1 Feb 96 00:38:59 -0500
  6. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  7. Message-ID: <BDNphyL.stonelight@delphi.com>
  8. References: <4eml5o$o6h@airdmhor.gen.nz>
  9. NNTP-Posting-Host: bos1f.delphi.com
  10. X-To: Simon Hosie <gumboot@airdmhor.gen.nz>
  11.  
  12. Simon Hosie <gumboot@airdmhor.gen.nz> writes:
  13.  
  14. >  12:     d = a | b | c;
  15. >  13: 
  16. >  14:     d |= a;
  17. >  15: 
  18. >  16:     d |= a | b;
  19. >  17:     d = d | a | b;
  20.  
  21.    Ah, the problem for the warnings (integer may be truncated) is probably
  22. that Watcom is generating intermediate code which (in the case of line 12)
  23. first does a bitwise-OR b, and stores it in an int (not a SHORT int), and then
  24. does the other bitwise-OR.  In fitting that back into d, there would be
  25. truncation (although it is not relevant in this example) when squeezing the
  26. int into a short int again.  The lines which did not produce warnings in-
  27. volved |= which dumps the result into d.
  28.  
  29.    This is just conjecture, but perhaps the definition for the |-operator
  30. on short ints (and int-promotion) and the |=-assignment operator are handled
  31. differently in C++ (as in that language | can have meaning for spoons and
  32. forks, if defined so.. :) ).
  33.  
  34.                                                 -- Stone
  35. --
  36. ... Old programmers never die, they just get lost in the loop.
  37.